Skip to content

feat: label MAC addresses that begin with 52 as Locally Admined MAC - #457

Open
TheWitness wants to merge 3 commits into
developfrom
feat/mactrack-locally-admined-mac
Open

TheWitness wants to merge 3 commits into
developfrom
feat/mactrack-locally-admined-mac

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Summary

A MAC address whose first octet is 52 is locally administered, so no vendor registers it and the OUI database cannot name it. The MAC Addresses and IP Addresses views now show Locally Admined MAC as the vendor for any address that begins with 52 and that the OUI database does not name. 52:54:00 stays Virtual/KVM Host.

How it works

The label is worked out when a view runs, not stored. mactrack_vendor_name_sql() returns COALESCE(mtod.vendor_name, IF(SUBSTRING(mac, 1, 2) = '52', 'Locally Admined MAC', NULL)). The views select that expression as vendor_name, and their search filter uses the same expression, so the label is displayed, sorted, exported and searchable.

I chose this over discovery-time labelling because:

  • Existing scan data is covered at once, with no rescan, upgrade or migration.
  • There is nothing extra to store or keep in step on the large port and IP tables.
  • The other option, putting 52:xx:xx rows in the OUI table, needs 65,535 rows that every full IEEE import would delete.

A registered OUI row always wins over the label.

mactrack_get_vendor_name() (currently unused) applies the same fallback.

Tests

  • Unit tests cover the label, the SQL expression, the lookup helper, and that both views and their search use the expression.
  • A database test (it runs when MACTRACK_TEST_DSN is set, as it is in CI) runs the expression against real tables. It checks that 52:54:00 keeps its OUI name, other 52 addresses are labelled, other addresses are untouched, and searching Locally Admin finds them.

The full suite passes against MariaDB (1128 tests). locales/po/cacti.pot is updated for the one new string.

Note

The request was for addresses that begin with 52. The IEEE locally administered bit also covers first octets ending in 2, 6, A or E (for example 02, 0A, DA). This PR leaves those unlabelled, as requested.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 18:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The fallback incorrectly labels full MAC addresses as locally administered even when a matching vendor row exists because the lookup uses eight characters instead of the six-character OUI key.

1 open issue
What changed in this PR

Adds a query-time Locally Admined MAC vendor label to Device Tracking’s MAC and IP address views for unnamed MAC addresses beginning with 52. Existing scan data is covered without a rescan or migration, with OUI names intended to take precedence.

Changes:

  • Adds shared fallback helpers and uses the computed vendor name for display, sorting, export, and search.
  • Adds unit and optional database tests for labelling, vendor precedence, and search.
  • Updates the translation template and changelog.
File Description
tests/​Unit/​LocallyAdministeredMacTest.php Tests label helpers, SQL generation, lookup fallback, and view integration.
tests/​Integration/​LocallyAdministeredMacDatabaseTest.php Tests vendor precedence and label searches using temporary database tables.
mactrack_view_macs.php Uses computed vendor names in MAC queries and searches.
mactrack_view_arp.php Uses computed vendor names in IP queries and searches.
locales/​po/​cacti.pot Adds the new vendor label to the translation template.
lib/​mactrack_functions.php Defines fallback helpers and updates vendor lookup behaviour.
CHANGELOG.md Documents the new query-time vendor label.

Review effort: Balanced

Comment thread lib/mactrack_functions.php Resolved
xmacan
xmacan previously approved these changes Nov 17, 2026
…tabase test into the existing class

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
xmacan
xmacan previously approved these changes Nov 17, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants